<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>过滤选择器-内容过滤器</title>
<script type="text/javascript" src="js/jquery-1.5.js"></script>
<script type="text/javascript">
	$(function() {
		//1.:contains 匹配包含给定文本的元素
		$("div:contains('J')").css("backgroundColor","#EEE");
		//
		//2.:empty 匹配所有不包含子元素或者文本的空元素
		$("td:empty").text("empty");
		//3.:has("p") 匹配含有选择器所匹配的元素的元素
		$("div:has('p')").css("backgroundColor","#EEE");
		//4.parent 匹配含有子元素或者文本的元素
		$("td:parent").css("backgroundColor","red");
	});
</script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
<table>
  <tr><td>Value 1</td><td></td></tr>
  <tr><td>Value 2</td><td></td></tr>
</table>
<div><p>Hello</p></div>
<div>Hello again!</div>
</body>
</html>